import Compiler from '../compiler'
import Util from '../util'
import initData from '../instance/init'

//组件工厂，options是构造器
function Vue(el, options, attach) {

    //为v-for使用
    let forPrefix;
    if (attach) {
        this.parent = attach.parent;
        this.forPrefix = attach.forPrefix
    }

    this.el = typeof el === 'string'
        ? document.querySelector(el)
        : el;
    this.$options = options

    Util.extend(this, options.methods);

    //把组件构造器的data注入到组件实例
    initData(this)

    Compiler.compile.call(this, this.el);
}

export default Vue;


